package io;

import java.io.*;
import java.util.Scanner;

public class NoteDemo {
    public static void main(String[] args) throws Exception {
       Scanner scanner =new  Scanner(System.in);
        System.out.println("输入文件名");
        String fileName = scanner.nextLine();

        PrintWriter pw = new PrintWriter(
           new BufferedWriter(
                   new OutputStreamWriter(
                           new FileOutputStream(fileName),"UTF-8"
                   )
           ),true
        );

        System.out.println("输入内容，输入exit结束");
        while (true){
            String line = scanner.nextLine();
            if ("exit".equals(line)){
                break;
            }
           pw.println(line);
        }
        System.out.println("写出完毕");
        pw.close();
    }
}
